package com.changgou.order.controller;


import com.changgou.entity.PageResult;
import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.order.pojo.Evaluate;
import com.changgou.order.service.EvaluateService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/evaluate")
public class EvaluateController {
    @Autowired
    private EvaluateService evaluateService;


    /***
     * 修改数据
     * @param evaluate
     * @param id
     * @return
     */
    @PutMapping(value = "/{id}")
    public Result update(@RequestBody Evaluate evaluate, @PathVariable("id") String id) {
        evaluate.setId(id);
        evaluateService.update(evaluate);
        return new Result(true, StatusCode.OK, "修改成功");
    }



    @PostMapping(value = "/search/{page}/{size}" )
    public Result findPage(@RequestBody Map searchMap, @PathVariable("page")  int page, @PathVariable("size")  int size){
        Page<Evaluate> pageList = evaluateService.findPage(searchMap, page, size);
        PageResult pageResult = new PageResult(pageList.getTotal(), pageList.getResult());
        return new Result(true, StatusCode.OK, "查询成功", pageResult);
    }






}
